create table Schedule
(
	 [ScheduleId] int identity(1, 1) primary key
	,[BeginLocation] int
	,[EndLocation] int
	,[CreatedBy] int
	,[CreatedDate] datetime
	,[UpdatedBy] int
	,[UpdatedDate] datetime
	,[Status] int
)
go

CREATE PROCEDURE ScheduleGet
	@ScheduleId int
AS
SELECT *
FROM [Schedule]
WHERE[Schedule].[ScheduleId] = @ScheduleId
GO

CREATE PROCEDURE ScheduleList
AS
SELECT *
FROM [Schedule]
ORDER BY ScheduleId DESC
GO

CREATE PROCEDURE ScheduleInsert
	@BeginLocation int
	,@EndLocation int
	,@CreatedBy int
	,@CreatedDate datetime
	,@UpdatedBy int
	,@UpdatedDate datetime
	,@Status int
AS

INSERT INTO Schedule (
	 [BeginLocation]
	,[EndLocation]
	,[CreatedBy]
	,[CreatedDate]
	,[UpdatedBy]
	,[UpdatedDate]
	,[Status]
	
) VALUES (
	 @BeginLocation
	,@EndLocation
	,@CreatedBy
	,@CreatedDate
	,@UpdatedBy
	,@UpdatedDate
	,@Status
	
)

select SCOPE_IDENTITY()
GO

CREATE PROCEDURE ScheduleUpdate
	@ScheduleId int, 
	@BeginLocation int, 
	@EndLocation int, 
	@CreatedBy int, 
	@CreatedDate datetime, 
	@UpdatedBy int, 
	@UpdatedDate datetime, 
	@Status int 

AS

UPDATE Schedule SET
	   [BeginLocation] = @BeginLocation
	   ,[EndLocation] = @EndLocation
	   ,[CreatedBy] = @CreatedBy
	   ,[CreatedDate] = @CreatedDate
	   ,[UpdatedBy] = @UpdatedBy
	   ,[UpdatedDate] = @UpdatedDate
	   ,[Status] = @Status
WHERE [Schedule].[ScheduleId] = @ScheduleId
GO

CREATE PROCEDURE ScheduleDelete
	@ScheduleId int
AS
DELETE FROM Schedule
WHERE [Schedule].[ScheduleId] = @ScheduleId
GO